<include file="Public/head"/>
<body class="no-skin">
<include file="Public/header"/>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <include file="Public/sidebar"/>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs"/>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set"/>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <div class="row">
                            <form class="form-inline" action="" method="get">
                                <label class="inline">模块名称：</label>
                                <input type="text" name="keyword" value="{:I(keyword)}" class="form-control">
                                <button type="submit" class="btn btn-purple btn-sm">
                                    <span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
                                    Search
                                </button>
                            </form>
                        </div>
                        <div class="space-4"></div>
                        <div class="row">
                            <form id="form" method="post" action="{:U('del')}">
                                <table class="table table-striped table-bordered table-hover" id="simple-table">
                                    <thead>
                                    <tr>
                                        <th>模块名称</th>
                                        <th>模块别名</th>
                                        <th>模块简介</th>
                                        <th class="center">模块版本</th>
                                        <th class="center">状态</th>
                                        <th class="center">详情</th>
                                        <th class="center">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <volist name="lists" id="val">
                                        <tr>
                                            <td>{$val['title']}</td>
                                            <td>{$val.module}</td>
                                            <td>{$val['description']}</td>
											<td class="center">
											<eq name="val.status" value="1">
											原版本：{$val.org_version}<br>新版本：{$val.version}
											<else />
											{$val.version}
											</eq>
											</td>
                                            <td class="center"><eq name="val.status" value="0">未安装<else/>已安装</eq></td>
											<td class="center">
												<div class="action-buttons">
													<a href="#" class="green bigger-140 show-details-btn" title="显示方法信息">
														<i class="ace-icon fa fa-angle-double-down"></i>
														<span class="sr-only">Details</span>
													</a>
												</div>
											</td>
                                            <td class="center">
												<switch name="val.status">
													<case value="0">
														<a href="{:U('ApiPlug/Install',array('data' => $val['module']))}" menu="tips_menu" title="确定要安装这个接口插件？">安装</a>
													</case>
													<case value="1">
														<a href="{:U('ApiPlug/Upgrade',array('data' => $val['module']))}" menu="tips_menu" title="确定要升级这个接口插件？">升级</a> | 
														<a href="{:U('ApiPlug/UnInstall',array('data' => $val['module']))}" menu="tips_menu" title="确定要卸载这个接口插件？">卸载</a>
													</case>
													<case value="2">
														<a href="{:U('ApiPlug/UnInstall',array('data' => $val['module']))}" menu="tips_menu" title="确定要卸载这个接口插件？">卸载</a>
													</case>
												</switch>
											</td>
                                        </tr>
										<tr class="detail-row" style="display:none;">
											<td colspan="8">
												<eq name="val.status" value="1">
												<div class="alert alert-block alert-success">
													<table>
														<tr>
															<td width="100">升级信息</td>
															<td>{$val.save_info}</td>
														</tr>
													</table>
												</div>
												</eq>
												<div class="table-detail">
												<volist name="val.method" id="vo">
													<div class="col-xs-12 col-sm-100" style="margin-top:10px;">
														<div class="space visible-xs"></div>
														<div class="profile-user-info profile-user-info-striped">
															<div class="profile-info-row">
																<div class="profile-info-name"> 方法名称 </div>

																<div class="profile-info-value">
																	<span>{$vo.title}</span>
																</div>
															</div>

															<div class="profile-info-row">
																<div class="profile-info-name"> 方法别名 </div>

																<div class="profile-info-value">
																	<span>{$vo.method}</span>
																</div>
															</div>

															<div class="profile-info-row">
																<div class="profile-info-name"> 简介 </div>

																<div class="profile-info-value">
																	<span>{$vo.description}</span>
																</div>
															</div>

															<div class="profile-info-row">
																<div class="profile-info-name"> 请求方式 </div>

																<div class="profile-info-value">
																	<span>{$vo.allowMethod}</span>
																</div>
															</div>
															<div class="profile-info-row">
																<div class="profile-info-name"> 请求字段 </div>
																<style>
																	.request_fields{ width:100%;}
																	.request_fields dl{ margin-bottom:0px; }
																	.request_fields dl dd{ line-height:200%; font-size:14px; border-top:1px dashed #ccc; float:left; width:100%;}
																	.request_fields dl dd span{ float:left; }
																	.request_fields dl dd a{ padding:2px 5px; color:#fff; margin-top:6px; display:block; float:left; background:#336199;line-height:100%; }
																	.json_data{ width:40%; display:none; float:left; border:1px solid #F4A460; margin:5px 0px 5px 10px; background:#FFE4B5}
																	.json_data span{ width:100%;}
																</style>
																<div class="request_fields">
																	<dl>
																		<foreach name="vo.request_parameter" key="key" item="v">
																		<dd <eq name="key" value="0">style="border-top:none;"</eq>>
																			<span>【 {$v[0]} => {$v[1]}( <eq name="v.2" value="1">不能为空<else/>可为空</eq> / {$v[3]} ) 】</span>
																			<eq name="v[3]" value="json">
																				<a href="javascript:;" id="click_json_data_list">+</a>
																				<div class="json_data">
																					<foreach name="v.6" item="v1">
																					<span>【 {$v1[0]} => {$v1[1]}( <eq name="v1.2" value="1">不能为空<else/>可为空</eq> / {$v1[3]} ) 】</span>
																					</foreach>
																				</div>
																			</eq>
																		</dd>
																		</foreach>
																	</dl>
																</div>
															</div>
															<div class="profile-info-row">
																<div class="profile-info-name"> 模式管理 </div>
																<div class="profile-info-value">
																	<span>
																		<switch name="vo.mode_type">
																			<case value="1">返回字段</case>
																			<case value="2">返回html</case>
																			<case value="3">返回成功失败</case>
																			<default />返回字段
																		</switch>
																	</span>
																</div>
															</div>
															<eq name="vo.mode_type" value="1">
															<div class="profile-info-row">
																<div class="profile-info-name"> 可用字段 </div>
																<div class="profile-info-value">
																	<span><volist name="vo.fields" id="v"> 【 {$v[0]} => {$v[1]} ({$v[2]}) 】  </volist></span>
																</div>
															</div>
															</eq>
														</div>
													</div>
												</volist>
												</div>
											</td>
										</tr>

                                    </volist>
                                    </tbody>
                                </table>
                            </form>
                        </div>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <include file="Public/footer"/>

</div><!-- /.main-container -->

<include file="Public/footerjs"/>
<!-- inline scripts related to this page -->
<script type="text/javascript">
    $(function () {
        $('[menu="tips_menu"]').click(function () {
            var _self = $(this);
            bootbox.confirm({
                title: "系统提示",
                message: _self.attr('title'),
                callback: function (result) {
                    if (result) {
                        window.location.href = _self.attr('href');
                    }
                },
                buttons: {
                    "cancel": {"label": "取消"},
                    "confirm": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
			return false;
        });
    });
	$('.show-details-btn').on('click', function(e) {
		e.preventDefault();
		var details_row_self = $(this).closest('tr').next();

		details_row_self.is(':visible') ? details_row_self.hide() : details_row_self.show();
		$(this).find(ace.vars['.icon']).toggleClass('fa-angle-double-down').toggleClass('fa-angle-double-up');
	});
	$('a#click_json_data_list').click(function(){
		if( $(this).text() == '+' ) {
			$(this).text('-')
			$(this).next().show();
		} else {
			$(this).text('+')
			$(this).next().hide();
		}
	});
</script>
</body>
</html>
